#pragma once
#include "util/condition.h"
#include "base/function.h"
#include "util/mutex.h"
#include "util/noncopyable.h"
#include "base/config.h"

#include <queue>
#include <vector>
#include <string>

namespace net_tools::base
{
  class Thread;
  class Threadpool : util::noncopyable
  {
  public:
    Threadpool(int pool_size = _C::WORK_THREAD_POOL_SIZE, int task_queue_max_size = _C::WORK_THREAD_POOL_QUEUE_SIZE);
    ~Threadpool();
    void Addtask(func task);

  private:
    void Thread_todo();
    std::queue<func> task_queue_;
    std::vector<Thread *> thread_vector_;
    size_t thread_pool_size_;
    size_t task_queue_max_size_;
    util::Mutex mutex_;
    util::Condition cond_;
  };

} // namespace net_tools::base